<style type="text/css">
  /* --- 取消数字输入框后面上下箭头 --- */
  .noArrow::-webkit-outer-spin-button,
  .noArrow::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }
  .noArrow {
    -moz-appearance: textfield;
  }
</style>
<div class="wrapper-md ng-scope">
  <div class="row">

    <div class="panel panel-default">
      <tabset class="tab-container" >

        <tab heading="机构列表" active="status.active" ng-click="cancel()">
          <div class="panel-body">
            <table id ="treetable" class="table table-striped table-bordered dataTable table-condensed tree_table" style="display: none;">
              <thead>
                <tr>
                  <th class="col-md-2 text-center">机构名称</th>
                  <th class="col-md-1 text-center">归属区域</th>
                  <th class="col-md-1 text-center">机构编码</th>
                  <th class="col-md-1 text-center">类型</th>
                  <th class="col-md-1 text-center">备注</th>
                  <th class="col-md-1 text-center">操作</th>
                </tr>
              </thead>
              <tbody>
                <tr ng-repeat="office in office_list" id="{{office.id}}" pid="{{office.parent_id}}" sort="{{office.sort}}" officeloadover>
                  <td ><a href ng-click="update(office)" style="color:#2fa4e7">{{office.name}}</a></td>
                  <td class="text-center">{{office.area_name}}</td>
                  <td class="text-center">{{office.code}}</td>
                  <td class="text-center">{{office.type_c}}</td>
                  <td class="text-center">{{office.remarks}}</td>
                  <td>
                    <div ng-if="office.flag == 1">
                      <button type="button" class="btn btn-info btn-xs" ng-click="update(office)">修改</button>
                      <!-- <button type="button" ng-class="{true: 'btn btn-success btn-xs', false: 'btn btn-danger btn-xs'}[office.USEABLE == 0]"
                       ng-click="openANDstop(office)">{{office.USEABLE == 0?'开启':'停用'}}</button>  -->
                    </div>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
        </tab>

        <tab heading={{tabname.name}} ng-click="add(office_list[0])" active="tabname.active">
          <div class="panel-body">
            <form name="form1" class="form-horizontal ng-pristine ng-valid-required">
              <div class="form-group" ng-if="status.addSub">
                <label class="col-lg-2 control-label">上级机构:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" ng-model="obj.super_name" ng-disabled="true">
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">机构名称:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" ng-model="obj.name" placeholder='必填'>
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">归属区域:</label>
                <div class="col-lg-4">
                  <ui-select ng-model="obj.area_id" theme="bootstrap">
                    <ui-select-match placeholder="选择区域..">{{$select.selected.name}}</ui-select-match>
                    <ui-select-choices repeat="item.id as item in cityList | filter: $select.search">
                      <span ng-bind-html="item.name | highlight: $select.search"></span>
                    </ui-select-choices>
                  </ui-select>
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">电话:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" ng-model="obj.phone">
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">联系地址:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" ng-model="obj.address">
                </div>
              </div>
              <div class="form-group">
                <label class="col-lg-2 control-label">负责人:</label>
                <div class="col-lg-4">
                  <input type="text" class="form-control" ng-model="obj.master">
                </div>
              </div>
              <!-- 修改机构时显示 -->
              <div ng-if="!status.addSub">
                <div class="form-group">
                  <label class="col-lg-2 control-label">主负责人:</label>
                  <div class="col-lg-4">
                    <input type="text" class="form-control" ng-model="obj.PRIMARY_PERSON">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-lg-2 control-label">副负责人:</label>
                  <div class="col-lg-4">
                    <input type="text" class="form-control" ng-model="obj.DEPUTY_PERSON">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-lg-2 control-label">邮政编码:</label>
                  <div class="col-lg-4">
                    <input type="text" class="form-control"  ng-model="obj.zip_code">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-lg-2 control-label">传真:</label>
                  <div class="col-lg-4">
                    <input type="text" class="form-control" ng-model="obj.fax">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-lg-2 control-label">邮箱:</label>
                  <div class="col-lg-4">
                    <input type="text" class="form-control" ng-model="obj.email">
                  </div>
                </div>
              </div>

              <div class="form-group">
                <label class="col-lg-2 control-label">备注信息:</label>
                <div class="col-lg-4">
                  <textarea class="form-control" rows="3" ng-model="obj.remarks"></textarea>
                </div>
              </div>
              <div ng-show="status.addSub">
                <div class="form-group">
                  <div class="col-lg-8 col-lg-offset-2">
                    <i>添加默认的同名登录用户，初始密码:000000。</i>
                  </div>
                </div>
                <!-- 添加默认账号时显示  -->
                <div class="form-group">
                  <label class="col-lg-2 control-label">登录手机号:</label>
                  <div class="col-lg-4">
                    <input type="number" class="form-control noArrow" ng-model="obj.mobile">
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-lg-2 control-label">角色:</label>
                  <div class="col-lg-7">
                    <label ng-repeat="info in role_list" style="margin-bottom:2px; margin-right:2px; width:116px" 
                    class="btn btn-md btn-default" ng-model="info.active">
                      <i class="fa fa-check"></i>
                      <span class="text">{{info.name}}</span>
                    </label>
                  </div>
                </div>
              </div>

            </form>
            <div class="col-lg-2"></div>
            <div class="col-lg-4">
              <button class="btn btn-primary btn-rounded" ng-click="save()">保存</button>
              <button class="btn btn-default btn-rounded" ng-click="cancel()">取消</button>
            </div>
          </div>
        </tab>

      </tabset>
    </div>

  </div>
</div>


